package com.appistry.storage.rest;

import java.io.InputStream;
import java.net.InetAddress;

import com.appistry.api.rest.domain.RestResponse;
import com.appistry.api.rest.exception.RestException;
import com.appistry.storage.rest.domain.ControllerAction;

//TODO Docment this!
public interface RestStorageManager {
	public RestResponse listFiles(String filepath) throws RestException;
	public RestResponse listFilesWithMetaData(String filepath) throws RestException;	
	
	public RestResponse getFile(String filename) throws RestException;
	public RestResponse getFile(String filename, int minReadCopies) throws RestException;
	public RestResponse getFile(String filename, String version) throws RestException;
	public RestResponse getFile(String filename, String version, int minReadCopies) throws RestException;
	public RestResponse getFile(String filename, long offset, long length)throws RestException;
	public RestResponse getFile(String filename, int minReadCopies, long offset, long length) throws RestException;	
	public RestResponse getFile(String filename, String version, int minReadCopies, long offset, long length) throws RestException;
	
	public RestResponse putFile(String filename, InputStream inputstream) throws RestException;
	public RestResponse putFile(String filename, long length, InputStream inputstream) throws RestException;
	public RestResponse putFile(String filename, InputStream inputstream, int copies, int minCopies, int minReadCopies) throws RestException;
	
	public RestResponse moveFile(String filename, String dest) throws RestException;
	
	public RestResponse deleteFile(String filename) throws RestException;
	public RestResponse getFileLocation(String filename) throws RestException;
	public RestResponse getFileMetadata(String filename) throws RestException;
	
	public RestResponse listWorkers() throws RestException;
	public RestResponse listWorkers(boolean showDeleted) throws RestException;

	public RestResponse getWorkerResource(InetAddress ip) throws RestException;
	public RestResponse addWorkerResource(InetAddress ip) throws RestException;
	public RestResponse addWorkerResource(InetAddress ip, String territoryId) throws RestException;
	public RestResponse removeWorkerResource(InetAddress ip) throws RestException;
	public RestResponse getWorkerConfiguration(InetAddress ip) throws RestException;
	
	/**
	 * Controls a worker. The Actions include: start, stop.
	 * @param ip
	 * @param action
	 * @return RestResponse
	 * @throws RestException
	 */
	public RestResponse workerController(InetAddress ip, ControllerAction action) throws RestException;
	public RestResponse getWorkerStatus(InetAddress ip) throws RestException;
	public RestResponse getWorkerTerritory(InetAddress ip) throws RestException;
	public RestResponse putWorkerTerritory(InetAddress ip, String territory) throws RestException;
	public RestResponse getTerritories() throws RestException;
	public RestResponse getTerritoryWorkers(String territoryId) throws RestException;
	

}
